/**
 * 
 */
package org.vsg.stock.basic.persistence.mybatis;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.dao.DataAccessException;
import org.vsg.common.ibatis3.support.SqlSessionTemplateSupport;
import org.vsg.stock.basic.domain.VolFigureKlineDaily;
import org.vsg.stock.basic.persistence.VolFigureKlineDailyDao;

/**
 * @author Bill Vison
 *
 */
public class VolFigureKlineDailyDaoImpl extends SqlSessionDaoSupport implements
		VolFigureKlineDailyDao {
	

	@Override
	public List<VolFigureKlineDaily> findVolFiguKlineDailyInCycleByStck(
			String stockCode, String codeVoldFigureDetails, Date startDate,
			Date endDate) throws DataAccessException {
		String statement = "org.vsg.stock.basic.domain.mybatis.VolFigureKlineDailyProxy." +
				"findVolFiguKlineDailyInCycleByStck";
		
		Map<String,Serializable> params = new HashMap<String, Serializable>();
		params.put("stockCode", stockCode);
		params.put("codeVolFigureDetails", codeVoldFigureDetails );
		params.put("stockStartDate", startDate );
		params.put("stockDateEnd", endDate );

		List result  = this.getSqlSessionTemplate().selectList(statement, params);
		
		return (List<VolFigureKlineDaily>) result;
	}

	
	
	@Override
	public List<VolFigureKlineDaily> findAllVolFiguKlineDaily(String stockCode,
			String codeVoldFigureDetails) throws DataAccessException {
		String statement = "org.vsg.stock.basic.domain.mybatis.VolFigureKlineDailyProxy." +
		"findVolFiguKlineDaily";
		Map<String,Serializable> params = new HashMap<String, Serializable>();
		params.put("stockCode", stockCode);
		params.put("codeVolFigureDetails", codeVoldFigureDetails );


		List result  = this.getSqlSessionTemplate().selectList(statement, params);

		return (List<VolFigureKlineDaily>) result;
	}



	@Override
	public List<VolFigureKlineDaily> findVolFiguKlineDailyByCharacterPrepared(
			String stockCode) throws DataAccessException {
		// --- parse pattern ---

		Map<String,Serializable> params = new HashMap<String, Serializable>();
		params.put("stockCode", stockCode);
		
		String statement = "org.vsg.stock.basic.domain.mybatis.VolFigureKlineDailyProxy." +
		"findVolFiguKlineDailyByCharacterPrepared_stockCode";

		SqlSessionTemplate template = this.getSqlSessionTemplate();

		List result  = template.selectList(statement, params);
		
		List<VolFigureKlineDaily> lastResult = (List<VolFigureKlineDaily>) result;
		
		for (VolFigureKlineDaily inst : lastResult) {
			SqlSessionTemplateSupport.Helper.interceptTemplate(inst,
					template);
		}
		
		
		return lastResult;
	}
	
	

	
	
}
